package com.heima.user.controller;

import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.entity.ApUserAuth;
import com.heima.user.service.ApUserAuthService;
import com.heima.user.service.ApUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/api/v1/auth")
public class ApUserAuthController {

    @Autowired
    private ApUserAuthService apUserAuthService;

    //查询用户认证列表
    @PostMapping("/list")
    public PageResult<ApUserAuth> findByPage(@RequestBody AuthDto dto){
        return apUserAuthService.findByPage(dto);
    }

    //认证信息审核不通过
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        dto.setStatus(2);
        return apUserAuthService.auth(dto);
    }

    //认证信息审核通过
    @PostMapping("/authPass")
    public ResponseResult authPass(@Valid @RequestBody AuthDto dto){
        dto.setStatus(9);
        return apUserAuthService.auth(dto);
    }
}
